import { createVNode, render } from "vue";

import Message from "./Message.vue";

const divVNode = createVNode("div", { class: "xtx-message-containers" });
render(divVNode, document.body);

const div = divVNode.el;

const AllMessage = ({ message, type }) => {
  // 1. 动态创建虚拟DOM  createVNode(h) 函数
  const comVNode = createVNode(Message, { message, type });
  // 2. 渲染到body页面中  render函数
  // render(comVNode, document.body)
  render(comVNode, div);
  // 3. 提示在 6s 后自动卸载
  setTimeout(() => {
    render(null, div);
  }, 6000);
};

export default AllMessage;
